<template>
  <div class="search-container">
    <div class="button" @click="handleClick">+</div>
    <div class="input">
      <input @keyup="search" type="text" placeholder="请输入关键字" />
    </div>
  </div>
</template>

<script setup>
import { inject } from 'vue'
import _ from 'lodash'

const { setIsShow } = inject('dialogVisiable')
const { setKeyWords } = inject('keyWords')

function handleClick() {
  setIsShow(true)
}

const search = _.debounce((e) => {
  setKeyWords(e.target.value)
}, 500)

defineExpose({
  handleClick
})
</script>

<style lang="stylus" scoped>
div.search-container
  height 60px
  background #d3d3d3
  display  flex
  align-items center
  justify-content center
  padding-left 10px
  .button
    width 40px
    height 40px
    background-color #1e90ff
    padding-left 0
    font-size 30px
    font-weight bold
    color #fff
    display flex
    justify-content:center
    border-radius 5px
    position relative
    cursor pointer

  .input
     flex 1
     height 36px
     padding 0 10px
     border solid 1px #ccc
     border-radius 5px
     input
       height 100%
       width 100%
       outline none
       border solid 1px #ccc
       border-radius 5px
       padding 0 10px
</style>
